﻿using System.Web;
using System.Web.UI;
using System.Web.UI.MobileControls;
using Ue.Framework.Web.WebControls;
using Ue.Infrastructure.Web.UI;
using Ue.Qcdz.Domain;
using Ue.Qcdz.Domain.Membership;
using TextBox = System.Web.UI.WebControls.TextBox;

namespace Ue.Qcdz.UI.Controls
{
    public class PermissionEdit : SkinnedEntityEdit<Ue.Qcdz.Domain.Permissions.Permission>
    {
        private TextBox tbxName;
        private TextBox tbxFeatureName;
        private TextBox tbxDescription;
        private string sinkName = "~/Admin/Themes/Skins/Permission/PermissionEdit.ascx";
        protected override string GetSkinFileName()
        {
            return sinkName;
        }

        protected override Ue.Qcdz.Domain.Permissions.Permission Enttiy
        {
            get
            {

                return new Ue.Qcdz.Domain.Permissions.Permission(
                    tbxName.GetValue<string>(),
                    tbxFeatureName.GetValue<string>(),
                    tbxDescription.GetValue<string>(),
                     (object)this.EntityKey);
            }
            set
            {
                if (value == null)
                    return; ;
                tbxName.SetValue(value.Name);
                tbxFeatureName.SetValue(value.FeatureName);
                tbxDescription.SetValue(value.Description);
            }
        }

        protected override void InitSkin(Control skin)
        {
            tbxName = skin.FindControl<TextBox>("tbxName");
            
            tbxFeatureName = skin.FindControl<TextBox>("tbxFeatureName");
            tbxDescription = skin.FindControl<TextBox>("tbxDescription");
        }
    }
}
